package com.aretias.jkholdings.repository;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;

import com.aretias.jkholdings.model.Category;

@Repository
public class CategoryRepositoryImpl implements CategoryRepository {
	
	private static final String NAMESPACE = "aretias.category.";
	
	@Autowired
	private SqlMapClientTemplate client;
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Category> selectChildCategorys(Category param) {
		return client.queryForList( NAMESPACE + "selectChildCategorys", param);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Category> selectAllCategorys(){
		return client.queryForList( NAMESPACE + "selectAllCategorys");
	}
	
	@Override
	public Category selectFirstCategory(){
		return (Category) client.queryForObject( NAMESPACE + "selectFirstCategory");
	}
	
	@Override
	public Category selectCategoryFullName(Category param) {
		return (Category) client.queryForObject( NAMESPACE + "selectCategoryFullName", param);
	}
	
	@Override
	public void insertCategory(Category param){
		client.insert( NAMESPACE + "insertCategory" , param);
	}
	
	@Override
	public void deleteCategory(Category param){
		client.delete( NAMESPACE + "deleteCategory", param);
	}

	@Override
	public void deleteChildCategory(Category param) {
		client.delete( NAMESPACE + "deleteChildCategory", param);
	}
}
